﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="设备报废申请.aspx.cs" Inherits="syc.Jidong.设备报废申请" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
SelectCommand="select @编码=编码,@名称=isnull(名称,0),@型号=isnull(型号,'')
,@总成本=isnull(总成本,0),@投产日期=投产日期,@折旧年限=isnull(折旧年限,0)
,@出厂编号=isnull(出厂编号,''),@出厂日期=出厂日期,@安装地点=isnull(安装地点,'')
from 设备台账 where ID=@ID;
select @报废ID=ID,@报废日期=日期,@经办人=isnull(经办人,''),@磨损=isnull(磨损,''),@回收=isnull(回收,''),@折价=isnull(折价,0)
,@原因=isnull(原因,''),@鉴定意见=isnull(鉴定意见,''),@审批意见=isnull(审批意见,''),@备注=isnull(备注,'') from 设备报销申请 where 台账ID=@ID;
"
UpdateCommand="if @ID=0
begin return;
end
if @报废ID=0
begin
update 设备台账 set 状态=1 where ID=@ID;
insert into 设备报销申请(台账ID,日期,经办人,磨损,回收,折价,原因,鉴定意见,审批意见,备注)
values(@ID,@报废日期,@经办人,@磨损,@回收,@折价,@原因,@鉴定意见,@审批意见,@备注);
set @报废ID=@@IDENTITY;
end
else
begin
update 设备报销申请 set 日期=@报废日期,经办人=@经办人,磨损=@磨损,回收=@回收
,折价=@折价,原因=@原因,鉴定意见=@鉴定意见,审批意见=@审批意见,备注=@备注 where ID=@报废ID;
end
"

onselected="SqlDataSource1_Selected" onupdated="SqlDataSource1_Updated">
<SelectParameters>
<asp:Parameter Name="ID" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18" Direction="Output"/>
<asp:Parameter Name="名称" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="型号" DbType="AnsiString" Size="20" Direction="Output"/>
<asp:Parameter Name="总成本" DbType="Currency" Size="9" Direction="Output"/>
<asp:Parameter Name="投产日期" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="折旧年限" DbType="Int16"  Size="2" Direction="Output"/>
<asp:Parameter Name="出厂编号" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="出厂日期" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40" Direction="Output"/>

<asp:Parameter Name="报废ID" Size="4" DbType="Int32" Direction="Output"/>
<asp:Parameter Name="报废日期" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="经办人" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="磨损" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="回收" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="折价" DbType="Currency" Size="9" Direction="Output"/>
<asp:Parameter Name="原因" DbType="String"  Size="100" Direction="Output"/>
<asp:Parameter Name="鉴定意见" DbType="String"  Size="100" Direction="Output"/>
<asp:Parameter Name="审批意见" DbType="String"  Size="100" Direction="Output"/>
<asp:Parameter Name="备注" DbType="String"  Size="100" Direction="Output"/>

</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Size="4" DbType="Int32"/>
<asp:Parameter Name="报废ID" Size="4" DbType="Int32" Direction="InputOutput"/>
<asp:Parameter Name="报废日期" DbType="Date"  Size="3"/>
<asp:Parameter Name="经办人" DbType="String"  Size="20"/>
<asp:Parameter Name="磨损" DbType="String"  Size="40"/>
<asp:Parameter Name="回收" DbType="String"  Size="40"/>
<asp:Parameter Name="折价" DbType="Currency" Size="9"/>
<asp:Parameter Name="原因" DbType="String"  Size="100"/>
<asp:Parameter Name="鉴定意见" DbType="String"  Size="100"/>
<asp:Parameter Name="审批意见" DbType="String"  Size="100"/>
<asp:Parameter Name="备注" DbType="String"  Size="100"/>
</UpdateParameters>
</asp:SqlDataSource>

<asp:Label ID="BillID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="BaoFeiID" runat="server" Text="0" Visible="false"></asp:Label>

<div id="wintop" class="wintop">固定资产报废申请</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <asp:Button ID="Button_Save" runat="server" Text="确认报废" UseSubmitBehavior="false" 
    OnClientClick="if(!confirm('确认要报废吗？'))return(false);" CssClass="button" 
        onclick="Button_Save_Click" />
    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel">
<table border="1" style="border-collapse:separate;font-size:14px;">
	<tr height="30">
		<td width=100 align="right">资产编号:</td>
		<td width=150><asp:Label ID="BianHao0" runat="server" Text=""></asp:Label></td>
		<td width=100 align="right">资产名称:</td>
		<td width=150><asp:Label ID="MingCheng" runat="server" Text=""></asp:Label>　</td>
		<td width=100 align="right">规格型号:</td>
		<td width=150><asp:Label ID="XingHao" runat="server" Text=""></asp:Label>　</td>
	</tr>
	<tr height="30">
	    <td align="right">原 值:</td>
		<td><asp:Label ID="YuanZhi" runat="server" Text=""></asp:Label>元</td>
	    <td align="right">投产日期:</td>
		<td><asp:Label ID="Date1" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">折旧年限:</td>
		<td><asp:Label ID="NianXian" runat="server" Text=""></asp:Label>　</td>
	</tr>
	
	<tr height="30">
	    <td align="right">出产编号:</td>
		<td><asp:Label ID="ChuChangBH" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">出厂日期:</td>
		<td><asp:Label ID="Date2" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">安装地点:</td>
		<td><asp:Label ID="DiDian" runat="server" Text=""></asp:Label>　</td>
	</tr>
	
	<tr height="30">
		<td align="right">已用时间:</td>
		<td><asp:Label ID="YiYongNian" runat="server" Text=""></asp:Label>天</td>
		<td align="right">报废日期:</td>
		<td><asp:TextBox ID="Date3" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date3').value, document.getElementById('Date3'));" /></td>
		<td align="right">经办人:</td>
		<td><asp:TextBox ID="JingBanRen" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
	</tr>
	
	<tr height="30">
		<td align="right">磨损程度:</td>
		<td><asp:TextBox ID="MoSun" runat="server" CssClass="textbox" Width="120" ></asp:TextBox></td>
		<td align="right">可回收部件:</td>
		<td><asp:TextBox ID="HuiShou" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
		<td align="right">变价收入(元):</td>
		<td><asp:TextBox ID="ZheJia" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
	</tr>
	
	<tr height="30">
		<td align="right">详细报废原因:</td>
		<td colspan="3"><asp:TextBox ID="YuanYin" runat="server" CssClass="textbox" Width="378"></asp:TextBox></td>
	</tr>
	<tr height="30">
		<td align="right">鉴定小组意见:</td>
		<td colspan="3"><asp:TextBox ID="JianDing" runat="server" CssClass="textbox" Width="378"></asp:TextBox></td>
	</tr>
	
	<tr height="30">
		<td align="right">领导审批意见:</td>
		<td colspan="3"><asp:TextBox ID="ShenPi" runat="server" CssClass="textbox" Width="378"></asp:TextBox></td>
	</tr>
	
	<tr height="30">
		<td align="right">备 注:</td>
		<td colspan="3"><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="378"></asp:TextBox></td>
	</tr>
	
</table>

</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="" CssClass="prompt"></asp:Label>
</asp:Panel>

</form>

<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;
        if(e.keyCode==13)e.keyCode = 9;
    }

    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left = (getObjectLeft(o) + 0) + "px";
        ds.style.top = (getObjectTop(o) - 30) + "px";
        ds.style.display = 'block';
        showcalendar();
    }
</script>
</body>
</html>
